/*
 * @Author: ૮₍ ˙О˙₎ა
 * @Date: 2023-07-17 14:41:53
 */
import type { IAttrInfoList, reqAttrCategory } from '@/types/attr'
import { http } from '@/utils/request'

/**
 * @description: 一级分类数据
 * @return {*}
 */
export const reqGetCategory1 = () => {
  return http<reqAttrCategory[]>(`/admin/product/getCategory1`, 'GET')
}

/**
 * @description: 二级分类数据
 * @return {*}
 */
export const reqGetCategory2 = (id: number) => {
  return http<reqAttrCategory[]>(`/admin/product/getCategory2/${id}`, 'GET')
}

/**
 * @description: 三级分类数据
 * @return {*}
 */
export const reqGetCategory3 = (id: number) => {
  return http<reqAttrCategory[]>(`/admin/product/getCategory3/${id}`, 'GET')
}

/**
 * @description: 属性列表
 * @return {*}
 */
export const reqAttrInfoList = (category1Id: number, category2Id: number, category3Id: number) => {
  return http<IAttrInfoList[]>(
    `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
    'GET'
  )
}

/**
 * @description: 添加属性
 * @return {*}
 */
export const reqSaveAttrInfo = (date: IAttrInfoList) => {
  return http(`/admin/product/saveAttrInfo`, 'POST', date)
}

/**
 * @description: 编辑属性
 * @return {*}
 */
export const reqUpdateAttrInfo = (date: IAttrInfoList) => {
  return http(`/admin/product/saveAttrInfo`, 'POST', date)
}

/**
 * @description: 删除属性
 * @return {*}
 */
export const reqDeleteAttr = (attrId: number) => {
  return http(`/admin/product/deleteAttr/${attrId}`, 'DELETE')
}
